import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:projectfluttershengyihuatong/courseDetail/courseviewmodel.dart';
import 'package:projectfluttershengyihuatong/route.dart';

import 'CourseDetailModel.dart';



class CourseDetail extends StatelessWidget {
  const CourseDetail({super.key});


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: const SafeArea(child: CourseDetailPage()),
      floatingActionButton: FloatingActionButton(onPressed: () {
        Get.toNamed(RouteNames.AliHomePage);

      }, child: Icon(Icons.add),),
    );
  }
}


class CourseDetailPage extends StatefulWidget {
  const CourseDetailPage({super.key});
  @override
  State<CourseDetailPage> createState() => _CourseDetailPageState();
}

class _CourseDetailPageState extends State<CourseDetailPage> {
  @override
  void initState() {
    final args = Get.arguments as Map<String, String>;
    courseId = args["courseId"];
    kid = args["kid"];
    future = viewModel.request({"course_id": "57", "kid": kid ?? ""});
    // TODO: implement initState
    super.initState();
  }
  late Future<CourseDetailModel?> future;
  final viewModel = CourseDetailViewModel();
  late final String? courseId;
  late final String? kid;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.red,
      child: FutureBuilder(
        future: future,
        builder: (context,snapshot){
          if (snapshot.hasData) {
            return Container(
              child: Column(
                children: [

                ],
              ),
            );
          }
          return const Center(child: CircularProgressIndicator());
        },
      ),
    );
  }
}







